package com.pocketsweet.ui.uilib;

import java.util.ArrayList;
import java.util.List;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

public class MyFragmentPagerAdapter extends FragmentPagerAdapter {
	private List<Fragment> fragmentsList;
	private List<String> titleList;

	public MyFragmentPagerAdapter(FragmentManager fm) {
		super(fm);

	}

	public MyFragmentPagerAdapter(FragmentManager fm, List<Fragment> listViews) {
		super(fm);
		this.fragmentsList = listViews;
	}

	public MyFragmentPagerAdapter(FragmentManager fm,
			ArrayList<Fragment> fragments, ArrayList<String> titleList) {
		super(fm);
		this.fragmentsList = fragments;
		this.titleList = titleList;
	}

	@Override
	public int getCount() {
		return fragmentsList.size();
	}

	@Override
	public Fragment getItem(int arg0) {
		return fragmentsList.get(arg0);
	}

	/**
	 * 每个页面的title
	 */
	@Override
	public CharSequence getPageTitle(int position) {
		return (titleList.size() > position) ? titleList.get(position) : "";
	}

	@Override
	public int getItemPosition(Object object) {
		return super.getItemPosition(object);
	}

	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		// TODO Auto-generated method stub
		return super.instantiateItem(container, position);
	}
	

}
